home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / wtjmarch.zip / HATCH.ZIP / KPWIN.TXT < prev    next >
Text File  |  1992-02-21  |  1KB  |  47 lines

  1. FIGURE 2: KnowledgePro (Windows) example of Inheritance
  2.  
  3. topic Item.
  4.   (* Inventory class for stationery store. *)
  5.   :price is getPrice().
  6.   :supplier is getSupplier().
  7.   :onHand is getOnHand().
  8.  
  9.   topic getPrice.
  10.     (* Apply default 40% markup. *)
  11.     ask ('What is our cost?', cost).
  12.     getPrice is ?cost + (.40 * ?cost).
  13.   end.
  14.  
  15.   topic getSupplier.
  16.     getSupplier is 'East End Wholesale'.
  17.   end.
  18.  
  19.   topic getOnHand.
  20.     ask ('How many are on hand?', getOnHand).
  21.   end.
  22.  
  23. end.
  24.  
  25. topic PenItem.
  26.   (* PenItem is a subclass of Item. *)
  27.   im_a (Item).
  28.   topic getPrice.
  29.     (* PenItem's unique getPrice method. *)
  30.     ask('What is our cost?', cost).
  31.     getPrice is ?cost + (.50 * ?cost).
  32.   end.
  33. end. (* PenItem *)
  34.  
  35. topic PaperItem.
  36.   (* PaperItem is a subclass of Item. *)
  37.   im_a (Item).
  38.   topic getSupplier
  39.     getSupplier is 'Paper World'.
  40.   end.
  41. end. (* PaperItem *)
  42.  
  43. topic GiftItem
  44.   (* GiftItem is a subclass of Item. *)
  45.   im_a (Item).
  46. end. (* GiftItem *)
  47.